<?php
/**
 * Created by PhpStorm.
 * User: venki
 * Date: 2023/12/7
 * Time: 10:06
 */

namespace app\resources;

use yii\base\BaseObject;

class UserResource extends BaseObject
{
    public static function collection($models): array
    {
        $resources = [];
        foreach ($models as $model) {
            $resources[] = self::item($model);
        }
        return $resources;
    }

    public static function item($model): array
    {
        return [
            'id'         => (int)$model->id,
            'updated_at' => (string)$model->updated_at,
            'body'       => (string)$model->body,
            'title'      => (string)$model->title,
            // 其他字段...
        ];
    }
}

